local BaseData = require("data.base.BaseData")
local ItemUnitData = class("ItemUnitData", BaseData)

local schema = {}
schema["id"] = {"number", 0}
schema["num"] = {"number", 0}
schema["config"] = {"table", {}}
ItemUnitData.schema = schema

function ItemUnitData:ctor()
    ItemUnitData.super.ctor(self)
end

function ItemUnitData:getType()
    local TypeHelper = require("utils.TypeHelper")
    return TypeHelper.TYPE_ITEM
end

function ItemUnitData:getBase_id()
    return self:getId()
end

function ItemUnitData:update(data, isAdd)
    local num = self:getNum()
    self:setProperties(data)
    if isAdd then
        local newNum = num + data.num
        self:setNum(newNum)
    end
end

function ItemUnitData:getPureData()
    local param = {}
    param.id = self:getId()
    param.num = self:getNum()
    return param
end

return ItemUnitData
